-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Provide context for macro expansions which result in unparsed tokens. #24078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
Thanks! Could you update the test case as well with this error message? I believe Also, could you rebase out the merge commit in the middle? |
//~ NOTE was indeed correct. @alexcrichton should be good to go |
Thanks! r? @kmcallister or @huonw or @sfackler (probably shoulda done that earlier as well..) |
When macro invocations expand to other macro invocations, I believe this fix only prints one of the call sites (either the immediate site or the earliest site, probably). Is that right? There will be a complete backtrace in the It seems there's a family of issues whose root cause is that we don't print a macro backtrace while we're parsing -- only after parsing/expansion has attached backtraces to spans. I'm wondering if they all have a single fix -- when we print a parsing error, also print the current Other issues include: |
That sounds like a good idea to me, although the specific information offered by this patch is good too. |
@bors r+ (We can add/swap in a more general approach in future.) |
📌 Commit ab32154 has been approved by |
Addresses issue #22425. See `src/test/compile-fail/macro-incomplete-parse.rs` for a relevant test: macro-incomplete-parse.rs:15:9: 15:10 error: macro expansion ignores token `,` and any following macro-incomplete-parse.rs:15 , //~ ERROR macro expansion ignores token `,` ^ macro-incomplete-parse.rs:27:1: 27:17 note: caused by the macro expansion here; the usage of `ignored_item` is likely invalid in this context macro-incomplete-parse.rs:27 ignored_item!(); ^~~~~~~~~~~~~~~~ macro-incomplete-parse.rs:20:14: 20:15 error: macro expansion ignores token `,` and any following macro-incomplete-parse.rs:20 () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` ^ macro-incomplete-parse.rs:30:5: 30:21 note: caused by the macro expansion here; the usage of `ignored_expr` is likely invalid in this context macro-incomplete-parse.rs:30 ignored_expr!(); ^~~~~~~~~~~~~~~~ macro-incomplete-parse.rs:24:14: 24:15 error: macro expansion ignores token `,` and any following macro-incomplete-parse.rs:24 () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` ^ macro-incomplete-parse.rs:32:9: 32:23 note: caused by the macro expansion here; the usage of `ignored_pat` is likely invalid in this context macro-incomplete-parse.rs:32 ignored_pat!() => (), ^~~~~~~~~~~~~~ This does not address the case of improper expansion inside of an impl { } as seen in issue #21607. I'm not sure if the note text is ideal, but it can be refined if needed.
💔 Test failed - auto-mac-32-opt |
@bors: retry |
Addresses issue #22425. See `src/test/compile-fail/macro-incomplete-parse.rs` for a relevant test: macro-incomplete-parse.rs:15:9: 15:10 error: macro expansion ignores token `,` and any following macro-incomplete-parse.rs:15 , //~ ERROR macro expansion ignores token `,` ^ macro-incomplete-parse.rs:27:1: 27:17 note: caused by the macro expansion here; the usage of `ignored_item` is likely invalid in this context macro-incomplete-parse.rs:27 ignored_item!(); ^~~~~~~~~~~~~~~~ macro-incomplete-parse.rs:20:14: 20:15 error: macro expansion ignores token `,` and any following macro-incomplete-parse.rs:20 () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` ^ macro-incomplete-parse.rs:30:5: 30:21 note: caused by the macro expansion here; the usage of `ignored_expr` is likely invalid in this context macro-incomplete-parse.rs:30 ignored_expr!(); ^~~~~~~~~~~~~~~~ macro-incomplete-parse.rs:24:14: 24:15 error: macro expansion ignores token `,` and any following macro-incomplete-parse.rs:24 () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` ^ macro-incomplete-parse.rs:32:9: 32:23 note: caused by the macro expansion here; the usage of `ignored_pat` is likely invalid in this context macro-incomplete-parse.rs:32 ignored_pat!() => (), ^~~~~~~~~~~~~~ This does not address the case of improper expansion inside of an impl { } as seen in issue #21607. I'm not sure if the note text is ideal, but it can be refined if needed.
Addresses issue #22425. See
src/test/compile-fail/macro-incomplete-parse.rs
for a relevant test:This does not address the case of improper expansion inside of an impl { } as seen in issue #21607.
I'm not sure if the note text is ideal, but it can be refined if needed.